package com.commands
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.commands.Command;
	import com.events.LoginEvent;
	import mx.controls.Alert;
	import com.model.ModelLocator;
	import flash.events.Event;
	import flash.html.HTMLControl;
	import flash.net.URLRequest;
	import flash.net.URLLoader;
	import com.components.gestorQuiniela;
	import com.datos.Datos;
	import com.datos.ItemEscrutinio;
	import mx.core.Application;
	import com.events.CargarEvent;
	import com.controller.Controller;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;

	public class LoginCommand implements Command
	{
		private var modelLocator : ModelLocator = ModelLocator.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
	        var loginEvent:LoginEvent = LoginEvent(event);  
	        var usuario:String = loginEvent.usuario;
	        var password:String = loginEvent.password;
	        	        
	        modelLocator.usuario = usuario;
	        modelLocator.password = password;
	        modelLocator.nameUsuario = usuario.substring(0,usuario.indexOf("@",0));
	        	        
	        modelLocator.viewStackSelection = ModelLocator.VIEWING_LOGGED_IN_SCREEN;
          
            for (var i:uint=1;i<43;i++)
    	        modelLocator.arrayJornadas.addItem(i);    	             
			modelLocator.link = "http://62.22.102.31/PROYECTO_LAE/quiniela_actualizar.aspx?p1=1&p2=2006&p3=1";      	
	        
	        var eventCargar:CargarEvent = new CargarEvent(Controller.EVENT_CARGAR);
			CairngormEventDispatcher.getInstance().dispatchEvent(eventCargar);
	                
		}
	}
}